<?php
/**
 * @fileName:TruckBuilder.php
 * @project:basic_knowledge
 * @author : 吐火青蛙
 * @user : 吐火青蛙
 * @date : 2020/4/11
 *
 */

namespace miaosang\basicknowledge\design\builder;

use miaosang\basicknowledge\design\builder\BuilderInterface;
use miaosang\basicknowledge\design\builder\parts\Vehicle;
use miaosang\basicknowledge\design\builder\parts\Door;
use miaosang\basicknowledge\design\builder\parts\Engine;
use miaosang\basicknowledge\design\builder\parts\Wheel;
use miaosang\basicknowledge\design\builder\parts\Truck;
class TruckBuilder implements BuilderInterface
{
    /**
     * @var
     */
    private $trunk;
    public function createVehicle()
    {
        $this->trunk = new Truck();
    }

    public function addWheel()
    {
        $this->trunk->setParts('wheel1',new Wheel());
        $this->trunk->setParts('wheel2',new Wheel());
        $this->trunk->setParts('wheel3',new Wheel());
        $this->trunk->setParts('wheel4',new Wheel());
        $this->trunk->setParts('wheel5',new Wheel());
        $this->trunk->setParts('wheel6',new Wheel());
    }

    public function addEngine()
    {
        $this->trunk->setParts('trunkEngine',new Engine());
    }

    public function addDoors()
    {
        $this->trunk->setParts('rightDoor',new Door());
        $this->trunk->setParts('leftDoor',new Door());
    }

    public function getVehicle(): Vehicle
    {
        return $this->trunk;
    }
}
